<template>
	<view>
		<view class="bg-white p-20">
			<view class="  a-c">
				<view class="c-7" style="font-size: 14px;">
					请选择关联文章（系统文章添加内容）
				</view>
				<view class="banmi_input_val p-t-10">
					<uni-data-select @change="change" :value="article_id" :localdata="localdata_list">
					</uni-data-select>
				</view>
			</view>
			<view class="banmi_flex a-c p-20">
				<view class="banmi_input_name"></view>
				<view class="banmi_input_view">
					<button style="background-color: #007AFF;" type="primary" size="mini" @click="ajax_set"
						class="banmi_but">
						保存
					</button>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		components: {

		},
		data() {
			return {
				article_id: '',
				localdata_list: []
			}
		},
		onLoad(on) {
			this.id = on.article_id;
			this.Article_list_init();

		},
		methods: {
			async Article_list_init() {
				var that = this;
				let requestParams = {
					page: this.page,
					paginate: 2000,
				};
				const ret = await this.Banmikeji.Article_list(requestParams);
				if (ret.status == 200) {
					this.list = ret.data.list.data;
					var localdata_list = [];
					for (var i = 0; i < this.list.length; i++) {
						var find = {
							'text': this.list[i]['name'],
							'value': this.list[i]['id'],
						}
						localdata_list.push(find);
					}
					this.localdata_list = localdata_list;
					this.init();
				}
			},
			async init() {
				const ret = await this.Banmikeji.index_index({});
				this.find = ret.data
				this.article_id = this.find['article_' + this.id] || ''
			 

			},
			change(e) {
				this.article_id = e;

			},
			async ajax_set() {
				var that = this;
				that.requestParams = {};
				that.requestParams["article_" + this.id + ""] =  this.article_id
				that.requestParams['key'] =  "article_" + this.id + ""
			 // {"login_type":2,"key":"login_type"}
  console.log("that.requestParams: " + JSON.stringify(that.requestParams));
				const ret = await this.Banmikeji.Settings_set_key_sets(that.requestParams);
				uni.showToast({
					title: ret.msg,
					icon: 'none'
				})
				 


			},
		}

	}
</script>

<style>

</style>